import re
import urllib

f = urllib.urlopen("http://learnxinyminutes.com/")
pat = re.compile("/docs/")

for line in f:
    sea = pat.search(line)
    if sea:
        li = line.split("'")[1].split("/")
        if len(li) == 4:
            print line
            filename = li[2] + ".html"
            targeturl = "http://learnxinyminutes.com"+line.split("'")[1]
            print targeturl
            urllib.urlretrieve(targeturl,filename)

